from django.db import models
from libs import ModelMixin, human_datetime
from apps.account.models import User


class Template(models.Model, ModelMixin):
    name = models.CharField("流程模板名称", max_length=50, unique=True, help_text="流程模板名称")
    flow = models.CharField("节点明细", max_length=2000, null=True, help_text="节点明细")
    desc = models.CharField(max_length=255, null=True)

    created_at = models.CharField(max_length=20, default=human_datetime)
    created_by = models.ForeignKey(User, models.PROTECT, related_name='+')
    deleted_at = models.CharField(max_length=20, null=True)
    deleted_by = models.ForeignKey(User, models.PROTECT, related_name='+', null=True)

    def __repr__(self):
        return '<Template %r>' % self.name

    class Meta:
        db_table = 'workorder_template'
        ordering = ('-id',)
